package com.baosight.xcyber.tm.re.observer;

import com.alibaba.fastjson.JSONObject;
import com.zeroc.Ice.Current;
import com.zeroc.Ice.Identity;
import com.zeroc.IceGrid.ObjectInfo;
import com.zeroc.IceGrid.ObjectObserver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
public class ObjectObserverI implements ObjectObserver {
    public static Logger logger = LoggerFactory.getLogger(ObjectObserverI.class);
    @Override
    public void objectInit(ObjectInfo[] objectInfos, Current current) {
        System.out.println("objectInit "+ Arrays.stream(objectInfos).map(JSONObject::toJSONString));
    }

    @Override
    public void objectAdded(ObjectInfo objectInfo, Current current) {
        System.out.println("objectAdded "+objectInfo);
    }

    @Override
    public void objectUpdated(ObjectInfo objectInfo, Current current) {
        System.out.println("objectUpdated "+objectInfo);
    }

    @Override
    public void objectRemoved(Identity identity, Current current) {
        System.out.println("objectRemoved "+identity);
    }
}
